import { _decorator, sys } from 'cc';
import Singleton from '../base/Singleton';

export class StoreManager extends Singleton {

    static get Instance() {
        return super.GetInstance<StoreManager>()
    }

    /**
     * 设置本地缓存
     * @param key 
     * @param value 
     * @returns 
     */
    setItem(key: string, value: string){
        if(!value){
            return;
        }
        sys.localStorage.setItem(key, value);   
    }

    /**
     * 获取本地缓存
     * @param key 
     * @returns 
     */
    getItem(key: string){
        return sys.localStorage.getItem(key)
    }

    /**
     * 清除缓存
     * @param key 
     */
    removeItem(key: string){
        sys.localStorage.removeItem(key)
    }

    /**
     * 清空缓存
     */
    clear(){
        sys.localStorage.clear()
    }

}